package com.mxpio.erp.common.equipment.entity;

import com.mxpioframework.jpa.annotation.Generator;
import com.mxpioframework.security.entity.BaseEntity;
import com.mxpioframework.system.entity.TreeAble;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.persistence.*;
import java.util.List;


@Data
@EqualsAndHashCode(callSuper=false)
@Entity
@Table(name = "MB_ERP_KNOWLEDGE_TYPE")
@Schema(description="知识类型")
public class KnowledgeType extends BaseEntity implements TreeAble<KnowledgeType> {
    private static final long serialVersionUID=-1L;

    @Id
    @Generator
    @Column(name = "ID_")
    @Schema(description = "主键")
    private String typeId;

    @Column(name = "PARENT_ID_")
    @Schema(description = "父类型ID")
    private String parentId="root";

    @Column(name = "TYPE_NAME_")
    @Schema(description = "知识类型")
    private String typeName;


    @Transient
    private List<KnowledgeType> children;

    @Override
    public List<KnowledgeType> getTreeChildren() {
        return children;
    }

    @Override
    public String getCurrentNodeKey() {
        return typeId;
    }

    @Override
    public String getParentNodeKey() {
        return "root".equals(parentId) ? null : parentId;
    }

    @Override
    public void setTreeChildren(List<KnowledgeType> children) {
        this.children = children;
    }
}
